$(function () {



    // router
    $('.car').on('click', function () {
        location.href = "C:/Users/Administrator/Desktop/项目/kangkangs-tesco-project/cart.html"
    })

    $('.logo').on('click', function () {
        location.href = "file:///C:/Users/Administrator/Desktop/%E9%A1%B9%E7%9B%AE/kangkangs-tesco-project/index.html";
    })

    $('.order').on('click', function () {
        console.log("aaa");
        location.href = "C:/Users/Administrator/Desktop/项目/kangkangs-tesco-project/pay.html"
    })


    // 判断是否登录,如果已经登录就显示 欢迎登入
    let timer = setInterval(function () {
        let uname = localStorage.getItem("uname");
        let username = localStorage.getItem("username");
        let password = localStorage.getItem("password");
        let isLogin = localStorage.getItem("isLogin");
        if (uname && username && password && isLogin) {
            $(".show-user").html(`<p>欢迎您 : <span>${uname}<span> &nbsp;&nbsp;&nbsp; <a class="login-out" href="#">退出登入<a> <p>`)
            clearTimeout(timer)
            $('.login-out').on('click', function () {
                localStorage.removeItem("uname")
                localStorage.removeItem("password")
                localStorage.removeItem("username");
                localStorage.removeItem("isLogin");
                location.href = "file:///C:/Users/Administrator/Desktop/%E9%A1%B9%E7%9B%AE/kangkangs-tesco-project/login.html"
            })
        }
    })


    // 

    $('.option>ul>li:last').on('click', function () {
        location.href = "file:///C:/Users/Administrator/Desktop/%E9%A1%B9%E7%9B%AE/kangkangs-tesco-project/product.html"
        return false
    })

    console.log($('.option>ul>li:last'));

    $('.option>ul>li').eq(9).on('click', function () {
        location.href = "file:///C:/Users/Administrator/Desktop/%E9%A1%B9%E7%9B%AE/kangkangs-tesco-project/product-details.html";
    })




    // 跳转到购物车

    $('.addcar').on('click', function () {
        location.href = "file:///C:/Users/Administrator/Desktop/项目/kangkangs-tesco-project/cart.html"
    })

    $("#settle").on('click', function () {
        let uname = localStorage.getItem("uname");
        if (uname !== "" && uname) {
            localStorage.setItem('target', "file:///C:/Users/Administrator/Desktop/项目/kangkangs-tesco-project/cart.html")
            location.href = "file:///C:/Users/Administrator/Desktop/%E9%A1%B9%E7%9B%AE/kangkangs-tesco-project/pay.html"
            return false
        } else {
            alert("您还没有登录,请先登录")
            return false
        }


    })




})